package com.lfnyxy.service.imp;

import com.lfnyxy.dao.NewsTypeDao;
import com.lfnyxy.dto.DropVo;
import com.lfnyxy.entity.NewsTypeEntity;
import com.lfnyxy.query.NewsTypeQuery;
import com.lfnyxy.service.NewsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsTypeServiceImp implements NewsTypeService {
    @Autowired
    public NewsTypeDao newsTypeDao;

    public int CreateItem(NewsTypeEntity entity) {
        if (entity != null) {
            return newsTypeDao.CreateItem(entity);
        } else {
            return 0;
        }
    }

    public int UpdateItem(NewsTypeEntity entity) {
        if (entity != null) {
            return newsTypeDao.UpdateItem(entity);
        } else {
            return 0;
        }
    }

    public List <NewsTypeEntity> QueryPageList(NewsTypeQuery query) {
        int count = newsTypeDao.QueryPageListCount(query);
        query.setTotal(count);
            return newsTypeDao.QueryPageList(query);
    }

    public List <NewsTypeEntity> QueryAll() {
        return newsTypeDao.QueryAll();
    }

    public NewsTypeEntity QueryItem(int Id) {
        if (Id > 0) {
            return newsTypeDao.QueryItem(Id);
        } else {
            return null;
        }
    }

    public int DeleteItem(int Id) {
        if (Id > 0) {
            return newsTypeDao.DeleteItem(Id);
        } else {
            return 0;
        }
    }

    @Override
    public List <DropVo> QueryDrop(NewsTypeQuery query) {
        return newsTypeDao.QueryDrop(query);
    }

    private boolean CheckIsExist(NewsTypeEntity entity) {
        if (entity != null) {
            return newsTypeDao.CheckIsExist(entity) > 0;
        } else {
            return false;
        }
    }
}